﻿package src 
{
	import flash.display.MovieClip;
	import flash.events.Event;
	import flash.events.KeyboardEvent;
	import flash.ui.Keyboard;

	/**
	 * ...
	 * @author Ivan Lucas Neves
	 */
	public class Player_Cruiser extends MovieClip
	{
		
		//Bolleans to move and shoot the ship
		var MoveRight	:Boolean;
		var MoveLeft	:Boolean;
		var MoveUp		:Boolean;
		var MoveDown	:Boolean;
		var Shoot		:Boolean;
		
		public function Player_Cruiser() 
		{
			addEventListener(Event.ADDED_TO_STAGE, AddStage, false, 0, true);
			
		}
		
		private function AddStage(e:Event):void 
		{
			removeEventListener(Event.ADDED_TO_STAGE, AddStage);
			stage.addEventListener(KeyboardEvent.KEY_DOWN, Press, false, 0, true);
			stage.addEventListener(KeyboardEvent.KEY_UP, Release, false, 0, true);
			
		}
		
		
		public function Update():void
		{
			
		}
		
		private function Press(e:KeyboardEvent):void 
		{
			switch (e.keyCode) 
			{
				case Keyboard.RIGHT:
				MoveRight = true;					
				break;
				
				case Keyboard.LEFT:
				MoveLeft = true;					
				break;
				
				case Keyboard.UP:
				MoveUp = true;					
				break;
				
				case Keyboard.DOWN:
				MoveDown = true;					
				break;
				
				case Keyboard.SPACE:
				Shoot = true;					
				break;
				
			}
			
		}
		
		private function Release(e:KeyboardEvent):void 
		{
			switch (e.keyCode) 
			{
				case Keyboard.RIGHT:
				MoveRight = false;					
				break;
				
				case Keyboard.LEFT:
				MoveLeft = false;					
				break;
				
				case Keyboard.UP:
				MoveUp = false;					
				break;
				
				case Keyboard.DOWN:
				MoveDown = false;					
				break;
				
				case Keyboard.SPACE:
				Shoot = false;					
				break;
				
			}
		}
	}

}